#pragma once

#ifndef INT64_C
#define INT64_C(c) (c ## LL)
#define UINT64_C(c) (c ## ULL)
#endif

extern "C"
{
#include <libavutil/imgutils.h>
#include <libavutil/opt.h>
#include <libavcodec/avcodec.h>
#include <libavutil/audioconvert.h>
#include <libavutil/mathematics.h>
#include <libavutil/samplefmt.h>
}

#define INBUF_SIZE 4096
#define AUDIO_INBUF_SIZE 20480
#define AUDIO_REFILL_THRESH 4096

class VideoWriter
{
public:
	VideoWriter(void);
	~VideoWriter(void);

	void Start();
	void Write( char* buf );
	void Stop();

	void SetFileName( char* fileName );


private:
	char _fileName[ 256 ];
	
	AVCodecContext* _context;
	AVFrame* _picture;
	FILE*    _mp4file;
	bool     _startStatus;
	uint8_t* _videoBuffer;
	int      _bufferSize;
	int      _frameNumber;
	int      _outputSize;
	int      _hadOutput;
};

